<script setup>
import SportsNews from './components/SportsNews.vue'
import SportsMatches from './components/SportsMatches.vue'
import TeamRankings from './components/TeamRankings.vue'
import { ref } from 'vue'

const activeSection = ref('news')
</script>

<template>
  <div class="sports-app">
    <header class="app-header">
      <div class="header-content">
        <div class="logo-section">
          <h1>🏆 体育世界</h1>
          <p>一站式体育资讯平台</p>
        </div>
        <nav class="main-nav">
          <button 
            @click="activeSection = 'news'" 
            :class="{ active: activeSection === 'news' }"
            class="nav-button"
          >
            📰 体育新闻
          </button>
          <button 
            @click="activeSection = 'matches'" 
            :class="{ active: activeSection === 'matches' }"
            class="nav-button"
          >
            🏅 赛事安排
          </button>
          <button 
            @click="activeSection = 'rankings'" 
            :class="{ active: activeSection === 'rankings' }"
            class="nav-button"
          >
            📊 球队排名
          </button>
        </nav>
      </div>
    </header>

    <main class="app-main">
      <div class="content-container">
        <transition name="fade" mode="out-in">
          <SportsNews v-if="activeSection === 'news'" key="news" />
          <SportsMatches v-if="activeSection === 'matches'" key="matches" />
          <TeamRankings v-if="activeSection === 'rankings'" key="rankings" />
        </transition>
      </div>
    </main>

    <footer class="app-footer">
      <p>&copy; 2024 体育世界. 所有权利保留.</p>
    </footer>
  </div>
</template>

<style scoped>
.sports-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.app-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.logo-section h1 {
  font-size: 2rem;
  color: #2c3e50;
  margin: 0;
  font-weight: 700;
}

.logo-section p {
  color: #7f8c8d;
  margin: 5px 0 0 0;
  font-size: 0.9rem;
}

.main-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-button {
  padding: 12px 24px;
  border: none;
  border-radius: 25px;
  background: #ecf0f1;
  color: #2c3e50;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-button:hover {
  background: #bdc3c7;
  transform: translateY(-2px);
}

.nav-button.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.app-main {
  flex: 1;
  padding: 20px 0;
}

.content-container {
  max-width: 1200px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  min-height: 600px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.app-footer {
  background: rgba(255, 255, 255, 0.95);
  text-align: center;
  padding: 20px;
  color: #7f8c8d;
  font-size: 0.9rem;
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .logo-section h1 {
    font-size: 1.5rem;
  }
  
  .main-nav {
    justify-content: center;
  }
  
  .nav-button {
    padding: 10px 20px;
    font-size: 0.8rem;
  }
  
  .content-container {
    margin: 0 10px;
    border-radius: 15px;
  }
}
</style>
